﻿@using System.Data;
@using GatewayServer.Common;

@using UtilsBase;
@{
    ViewBag.PageTitle = "洪峰智能";

    Layout = "~/Views/Shared/PageTemplate.cshtml";
}

<script>
    $(document).ready(function () {

    });
    function createProductModel(guid) {
        $.post("createProductModel", { "flag": Math.random(), pmguid: guid }, function (result) {

            var myobj = (result.data);
            if (result.respCode == "200") {
                alert("产品型号创建成功！");
                window.location.href = "list";
            }

        });
        return;
    }
    function changeStatus(dguid) {
        $.post("changeStatus", { "flag": Math.random(), guid: dguid }, function (result) {
            var jsonresult = (result);
            if (jsonresult.respCode == "200") {
                window.location.reload();
            }
            else {
                alert(jsonresult.respMsg);
                return;
            }

        });

    }
</script>

<div id="saper-container">
    <form id="searchForm" name="searchForm" action="list" method="post">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>产品列表</h2>
            </div>
            <div class="subfiled-content">
                <div class="search-box clearfix">

                    <div class="kv-item clearfix">
                        <label>状态：</label>
                        <div class="kv-item-content">
                            <select id="status" name="status" style="width:130px;">
                                <option value="">全部</option>
                                @if (Model.status == "0")
                                {
                                    <option value="0" selected="selected">启用</option>
                                    <option value="1">禁用</option>
                                }
                                else if (Model.status == "1")
                                {
                                    <option value="0">启用</option>
                                    <option value="1" selected="selected">禁用</option>
                                }
                                else
                                {
                                    <option value="0">启用</option>
                                    <option value="1">禁用</option>
                                }

                            </select>
                        </div>
                    </div>

                    <div class="kv-item clearfix">
                        <label>名称：</label>
                        <div class="kv-item-content">
                            <input type="text" id="name" value="@Model.name" name="name" placeholder="名称" />
                        </div>
                    </div>
                    <a href="javascript:;" id="but_Search" name="but_Search" class="sapar-btn sapar-btn-recom query-btn">查询</a>
                </div>
                <!--表格开始-->
                <div class="table">
                    <!--表格操作-->
                    <div class="table-operate ue-clear">
                        <a href="edit" class="add" id="adda">添加</a>
                    </div>
                    <!--表格具体内容-->
                    <div class="table-box">
                        <table>
                            <thead>
                                <tr>
                                    @*                                    <th style="width:50px;"><input name="allbox" id="allbox" type="checkbox" value="" onclick="selectall()" /> 全选</th>
                                    *@
                                    <th>序号</th>
                                   
                                    <th>产品编号</th>
                                    <th>产品名称</th>
                                    <th>应用场景名称</th>
                                    <th>客户名称</th>
                                    <th>核验码</th>
                                    <th>状态</th>
                                     <th>产品型号</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                                @{
                                    int rowcount = 0; string result = "";
                                }
                                @foreach (DataRow item in (ViewData["DataList"] as DataTable).Rows)
                                {
                                    rowcount = rowcount + 1;
                                    <tr @Html.Raw(rowcount % 2 == 0 ? "style='background-color:#EFF6FA';" : "") id="tr_@rowcount" onclick="selectTr('@rowcount','15','@item["p_guid"]')">

                                        @*   <td>
                                    <input name="checkBox" type="checkbox" id="cb_@item["d_id"]" value="@item["d_id"]" />
                                    </td>*@
                                        <td>@(rowcount + ((int)ViewBag.PageIndex - 1) * (int)ViewBag.PageSize)</td>
                                      
                                        <td>@item["p_code"]</td>
                                        <td>@item["p_name"]</td>
                                        <td>@item["p_scene_name"]</td>
                                         <td>@item["c_name"]</td>
                                        <td>@item["p_check_code"]</td>
                                        <td>
                                            <a href="javascript:changeStatus('@(item["p_guid"])')">
                                                @(item["p_status"].ToString() == "0" ? "启用" : "禁用")
                                            </a>
                                         
                                        <td>@item["pm_name"]</td>
                                        <td>@(UtilsDateTime.getFormatTime(item["p_add_time"].ToString()))</td>
                                        <td>


                                            <a href="edit?order=upd&guid=@(item["p_guid"])">修改</a>
                                            
                                           @*  @if (String.IsNullOrEmpty(item["pm_name"].ToString()))
                                            {

                                                <a href="/ProductModel/edit?p_guid=@(item["p_guid"])&from=/Product/list">&nbsp; &nbsp;生成新型号模板</a>
                                            } *@
                                            &nbsp;&nbsp;
                                            <a href="/GateWay/list?p_guid=@(item["p_guid"])" target="_blank">网关</a>
                                              &nbsp;&nbsp;
                                            <a href="/Device/listZTree?p_guid=@(item["p_guid"])" target="_blank">设备</a>
                                            &nbsp;&nbsp;
                                            <a href="/DeviceLinkage/list?p_guid=@(item["p_guid"])" target="_blank">条件触发</a>
                                            &nbsp;&nbsp;
                                            <a href="/TaskPlain/list?p_guid=@(item["p_guid"])" target="_blank">运行流程</a>
                                             &nbsp;&nbsp;
                                            <a href="/TaskTimeInterval/list?p_guid=@(item["p_guid"])" target="_blank">定时任务</a>
                                            &nbsp;&nbsp;
                                            <a href="/TaskTimeFixed/list?p_guid=@(item["p_guid"])" target="_blank">指定时间</a>
                                            &nbsp;&nbsp;
                                            <a href="/TaskDefaultRun/list?p_guid=@(item["p_guid"])" target="_blank">自启动任务</a>
                                            &nbsp;&nbsp;
                                            <a href="/DeviceValueCurrentInterval/list?p_guid=@(item["p_guid"])" target="_blank">设备数据</a>
                                            &nbsp;&nbsp;
                                            <a href="/ProductLanguageCommon/list?p_guid=@(item["p_guid"])" target="_blank">公共多语言</a>
                                            &nbsp;&nbsp;
                                            <a href="/ProductLanguageAlone/list?pGuid=@(item["p_guid"])" target="_blank">定制多语言</a>
                                            &nbsp;&nbsp;
                                            <a href="/ProductServer/list?pGuid=@(item["p_guid"])" target="_blank">主机</a>
                                            &nbsp;&nbsp;
                                            <a href="/ProductCopy/copy?pguid=@(item["p_guid"])">复制产品</a>
                                        </td>
                                    </tr>
                                }
                                @if (rowcount < 1)
                                {
                                    <tr class="no-data"><td colspan="5" style="text-align:center">暂时没有数据</td></tr>
                                }
                            </tbody>
                        </table>
                        @Html.Raw(new GatewayServer.Common.PageHelper().GetPageHtml((int)ViewBag.RecordCount, (int)ViewBag.PageIndex, (int)ViewBag.PageCount))
                    </div>
                </div><!--表格结束-->
            </div>
        </div>
        <div id="saper-ft"></div>
    </form>
</div>
